Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@equinor/fusion-framework-module-event
Advanced tools
This package is meant for dispatching events between modules (siblings) and cross instances (parent|adjunct)
Base on the native node/web js event system, but the dispatcher is
async
for easier handling ofcancelable
events.NOTE that creating a
cancelable
event without awaiting resolution, will not respect thepreventDefault
behavior!
const configurator = (config) => {
/** disable propagation of all events */
delete config.event.onBubble
/** pre-handle all events before dispatch */
config.event.onDispatch = (e: FrameworkEvent) => {
if(!allow_event(e)){
e.preventDefault();
}
}
}
import { ModuleEvent } from '@equinor/fusion-framework-module-event';
/** declare event type for code completion */
declare module '@equinor/fusion-framework-module-event' {
interface ModuleEventMap {
'someEvent': FrameworkEvent<FrameworkEventInit<MyDataObject, MySource>>;
}
}
import { ModuleEvent } from '@equinor/fusion-framework-module-event';
type CustomFrameworkEventInit = FrameworkEventInit<MyDataObject, MySource>;
class MyCustomEvent extends FrameworkEvent<CustomFrameworkEventInit, 'myCustomEvent'> {
constructor(init: CustomFrameworkEventInit) { /** logic */ }
}
/** declare event type for code completion */
declare module '@equinor/fusion-framework-module-event' {
interface ModuleEventMap {
'myCustomEvent': MyCustomEvent;
}
}
const teardown = modules.event.addEventListener('someEvent', (event) => console.log(event));
// remove event listener
teardown();
// simple
const event = await modules.event.dispatchEvent(
'myEvent',
{
detail: 'some detail',
canBubble: false,
cancelable: true
}
);
// alternative
const event = new MyCustomFrameworkEvent(
'myCustomEvent',
{
detail: 'some detail',
canBubble: false,
cancelable: true
}
);
await modules.event.dispatchEvent(myEvent);
if(!event.defaultPrevent){
doSomeAction();
}
note that when subscribing to events, it does not allow side-effects, like
preventDefault
andstopPropagation
const subscription = modules.event.subscribe(console.log);
subscription.add(
modules.event.subscribe({
next: (event) => console.log(event),
error: (err) => console.error(err),
complete: () => 'event provider disposed'
})
);
// when unmount
subscription.unsubscribe();
FAQs
Fusion module for events
The npm package @equinor/fusion-framework-module-event receives a total of 1,658 weekly downloads. As such, @equinor/fusion-framework-module-event popularity was classified as popular.
We found that @equinor/fusion-framework-module-event demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.